/**
 * 
 */
package com.antilia.infomaresme.pages.details;

import java.util.ArrayList;
import java.util.List;

import org.apache.wicket.extensions.ajax.markup.html.repeater.data.table.AjaxFallbackDefaultDataTable;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.ResourceModel;

import com.antilia.infomaresme.data.dataobjects.Item;
import com.antilia.infomaresme.data.dataobjects.ItemNews;
import com.antilia.infomaresme.data.dataobjects.VisibilityStatus;
import com.antilia.infomaresme.provider.ItemNewssDataProvider;

/**
 * @author Ernesto
 *
 */
public class NewsPanel extends Panel {

	private static final long serialVersionUID = 1L;

	private ItemNewssDataProvider dataProvider;
	/**
	 * @param id
	 */
	public NewsPanel(String id, final IModel<Item> model) {
		super(id,model);
		
		List<IColumn<ItemNews>> columns = new ArrayList<IColumn<ItemNews>>();	
		columns.add(new PropertyColumn<ItemNews>(new ResourceModel("date"), null, "date"));
		columns.add(new PropertyColumn<ItemNews>(new ResourceModel("title"), null, "title"));
				
		
 		dataProvider = new ItemNewssDataProvider() {
			
			private static final long serialVersionUID = 1L;

			@Override
			protected VisibilityStatus getStatus() {
				// TODO Auto-generated method stub
				return VisibilityStatus.visible;
			}
			
			@Override
			public Item getItem() {
				return model.getObject();
			}
		};		
		AjaxFallbackDefaultDataTable<ItemNews> items  = new AjaxFallbackDefaultDataTable<ItemNews>("news", columns, dataProvider, 10);
		addOrReplace(items);
	}

}
